home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2001 Haziran / CHIP Haziran2001.iso / prog / share / 04 / setup.exe / MM27.Cab / F858_JSASample.cpp.0162E57D_7C98_4D94_A1CA_6231808F03E6 < prev    next >
Text File  |  2000-09-14  |  2KB  |  87 lines

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. *  Copyright 2000 Adobe Systems Incorporated
  7. *  All Rights Reserved.
  8. *
  9. * NOTICE:  All information contained herein is, and remains the property of 
  10. * Adobe Systems Incorporated  and its suppliers, if any.  The  intellectual 
  11. * and technical concepts contained herein are proprietary to  Adobe Systems 
  12. * Incorporated a nd its suppliers  and may be covered by U. S. and  Foreign 
  13. * Patents,patents in process,and are protected by trade secret or copyright 
  14. * law.  Dissemination of this information or reproduction  of this material
  15. * is strictly forbidden  unless prior  written permission  is obtained from 
  16. * Adobe Systems Incorporated.
  17. *
  18. **************************************************************************/
  19.  
  20. // ----------------------------------------------------------------
  21. // JSASample.c
  22. // Sample for the GoLive Extend Script SDK
  23. // requires the GoliveScript distribution order to compile
  24. // ----------------------------------------------------------------
  25.  
  26. #include "JSA++.h"
  27.  
  28. #include <math.h>
  29.  
  30. #ifdef WIN32
  31. #include <windows.h>
  32. #else
  33. #include <QuickDraw.h>
  34. #endif
  35.  
  36. // Implement this macro once to set up the necessary structures.
  37.  
  38. JSA_INIT;
  39.  
  40. // Return the power of arg1 to arg2.
  41.  
  42. static void power(int argc, const sValue* argv[], sValue* returnValue)
  43. {
  44.     double a = argv[0]->getDouble();
  45.     double b = argv[1]->getDouble();
  46.     
  47.     double c = pow (a, b);
  48.     
  49.     returnValue->setDouble (c);
  50. }
  51.  
  52. // Draw an oval into the given rectangle. This demonstrates the
  53. // use of the JSADrawInfo structure.
  54.  
  55. static void drawOval(int argc, const sValue* argv[], sValue* returnValue)
  56. {
  57.     int temp = argv[0]->getInteger();
  58.     JSADrawInfo* info;
  59. #ifdef WIN32
  60.     HDC dc;
  61.     info = (JSADrawInfo*) temp;
  62.     dc = (HDC) info->context;
  63.     ::Ellipse (dc, info->left, info->top, info->right, info->bottom);
  64. #else
  65.     info = (JSADrawInfo*) temp;
  66.     Rect r;
  67.     r.left = (short) info->left;
  68.     r.top = (short) info->top;
  69.     r.right = (short) info->right;
  70.     r.bottom = (short) info->bottom;
  71.     ::FrameOval (&r);
  72. #endif
  73. }
  74.  
  75. // Implement the JSAMain function to register all callable functions.
  76.  
  77. void JSAEXPORT JSAMain(void)
  78. {
  79.     JSARegisterFunction("power",power);
  80.     JSARegisterFunction("drawOval",drawOval);
  81. }
  82.  
  83. // optional, may be omitted
  84.  
  85. void JSAEXPORT JSAExit(void)
  86. {}
  87.